package org.itheima.game.org.tank.game.model

import org.itheima.game.org.tank.game.Config
import org.itheima.game.org.tank.game.business.Attackable
import org.itheima.game.org.tank.game.business.Blockable
import org.itheima.game.org.tank.game.business.Destroyable
import org.itheima.game.org.tank.game.business.Sufferable
import org.itheima.kotlin.game.core.Composer
import org.itheima.kotlin.game.core.Painter

/**
 * description ： 墙
 * author : chenmengjia
 * email : cmjsp1990@163.com
 * date : 2020/3/14 14:12
 */
class Wall(override var x: Int, override var y: Int) : Blockable, Sufferable, Destroyable {
    override fun isDestroyed(): Boolean = blood <= 0


    override var blood: Int = 3


    override fun notifySuffer(attackable: Attackable): Array<View>? {
        //掉血
        blood -= attackable.attackPower
        Composer.play("snd/hit.wav")
        return arrayOf(Blast(x, y))


    }

    override var width: Int = Config.block
    override var height: Int = Config.block

    override fun draw() {
        Painter.drawImage("img/wall.gif", x, y)
    }
}